package gewu.suleju.sevice.imp;

import gewu.suleju.dao.iml.IHouseInforDao;
import gewu.suleju.model.pojo.HouseInfor;
import gewu.suleju.sevice.IHouseInforService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service
public class HouseInforServiceImp implements IHouseInforService {
    @Autowired
    private IHouseInforDao iHouseInforDao;


    @Override
    public Page<HouseInfor> findPageAll(Integer pageNum, Integer pageSize) {
        Pageable pageable = PageRequest.of(pageNum - 1,pageSize);
        Page<HouseInfor> page = iHouseInforDao.findAll(pageable);
        return page;
    }

    @Override
    public HouseInfor findById(int id) {
        return iHouseInforDao.findById(id);
    }

    //by tjj

    @Override
    public List<HouseInfor> findHouseInforsByIdIn(List<Integer> houseIdList) {
        return iHouseInforDao.findHouseInforsByIdIn(houseIdList);
    }

    @Override
    public List<HouseInfor> findHouseInforsByUserId(Integer userid) {
        return iHouseInforDao.findHouseInforsByUserId(userid);
    }

    @Override
    public HouseInfor findHouseInforById(Integer id) {
        return iHouseInforDao.findHouseInforById(id);
    }
}
